package bean;

import java.sql.Time;
import java.util.ArrayList;

/**
 * Save the pub information into a bean.
 * 
 * @author Josef Hardi
 *
 */
public class PubBean {
	
	/** Pub's name **/
	private String name;
	
	/** Pub's address **/
	private String address;
	
	/** Pub's opening hour **/
	private String openHour;
	
	/** Pub's opening minute **/
	private String openMinute;
	
	/** Pub's closing hour **/
	private String closeHour;
	
	/** Pub's closing minute **/
	private String closeMinute;
	
	/** Pub's description **/
	private String description;
	
	/** Pub's facility **/
	private String facility;
	
	/** Pub's latitude location **/
	private int latitude;
	
	/** Pub's longitude location **/
	private int longitude;

	/** Pub's facilities **/
	private ArrayList<String> facilities = new ArrayList<String>();

	/**
	 * Getter for the pub's name
	 * 
	 * @return pub's name
	 */
    public String getName() {
    	return name;
    }
    
    /**
     * Setter for the pub's name
     * 
     * @param name pub's name
     */
    public void setName(String name) {
        this.name = name.trim();
    }
    
    /**
     * Getter for the pub's address
     * 
     * @return pub's address
     */
    public String getAddress() {
        return address;
    }
    
    /**
     * Setter for the pub's address
     * 
     * @param address
     */
    public void setAddress(String address) {
        this.address = address.trim();
    }
    
    /**
     * Getter for the pub's open time
     * 
     * @return pub's open time
     */
    public Time getOpenTime() {
    	return Time.valueOf(this.openHour + ":" + this.openMinute + ":00");
    }
    
    /**
     * Setter for the pub's open time
     * 
     * @param openHour
     */
    public void setOpenHour(String openHour) {
    	this.openHour = openHour;
    }
    
    /**
     * Setter for the pub's open time (in minute)
     * 
     * @param openMinute
     */
    public void setOpenMinute(String openMinute) {
    	this.openMinute = openMinute;
    }
    
    /**
     * Getter for the pub's closing time
     * 
     * @return pub's closing time
     */
    public Time getCloseTime() {
    	return Time.valueOf(this.closeHour + ":" + this.closeMinute + ":00");
    }
    
    /**
     * Setter for the pub's closing time
     * 
     * @param closeHour
     */
    public void setCloseHour(String closeHour) {
    	this.closeHour = closeHour;
    }
    
    /**
     * Setter for the closing time (in minute)
     * 
     * @param closeMinute
     */
    public void setCloseMinute(String closeMinute) {
    	this.closeMinute = closeMinute;
    }
    
    /** 
     * Getter for the pub's description
     * 
     * @return description
     */
    public String getDescription() {
    	return description;
    }
    
    /**
     * Setter for the pub's description
     * 
     * @param description
     */
    public void setDescription(String description) {
    	this.description = description.trim();
    }
    
    /**
     * Getter for the pub's facilities
     * 
     * @return pub's facilities
     */
    public String getFacility() {
    	
    	facility = "";
    	
    	int nFacility = facilities.size();
    	if (nFacility != 0) {
    		int i = 0;
    		for(; i < nFacility-1; i++)   
    			facility += facilities.get(i) + ", ";
    		facility += facilities.get(i);
    		
    		return facility;
    	}
    	else 
    		return facility;
    }
    
    /**
     * Setter for the pub's facilities
     * 
     * @param facility
     */
    public void setFacility(String facility) {
    	if (facility != null && facility != "null" )  // do not contain null string!
    		this.facilities.add(facility);
    }
    
    /**
     * Getter for the pub's latitude.
     * 
     * @return latitude
     */
    public int getLatitude() {
    	return latitude;
    }
    
    /**
     * Setter for the pub's latitude
     * 
     * @param latitude
     */
    public void setLatitude(int latitude) {
    	this.latitude = latitude;
    }
    
    /** 
     * Getter for the pub's longitude
     * 
     * @return pub's longitude
     */
    public int getLongitude() {
    	return longitude;
    }
    
    /**
     * Setter for the pub's longitude
     * 
     * @param longitude
     */
    public void setLongitude(int longitude) {
    	this.longitude = longitude;
    }
    
}
